/*
 * Copyright (C), 2014-2016, org.esaydev
 * FileName: WechatException.java
 * Author:   jian
 * Date:     2016年3月16日 下午2:30:53
 */
package org.easydev.wechat.common.exception;

import org.easydev.wechat.common.constants.WechatErrorCode;

/**
 * <Description> 微信异常<br>
 * 
 * @author jian<br>
 */
public class WechatException extends Exception {

    /**
     * serialVersionUID <br>
     */
    private static final long serialVersionUID = 4901508639434053737L;

    /**
     * 错误码
     */
    private String errorCode;

    /**
     * 错误信息
     */
    private String errorMsg;

    public WechatException() {
        setError(WechatErrorCode.SYSTEM_ERROR);
    }

    public WechatException(Throwable e) {
        super(e);
        setError(WechatErrorCode.SYSTEM_ERROR);
    }

    /**
     * @param errorEm
     */
    public WechatException(WechatErrorCode errorEm) {
        setError(errorEm);
    }

    private void setError(WechatErrorCode errorEm) {
        this.errorCode = errorEm.getCode();
        this.errorMsg = errorEm.getMessage();
    }

    /**
     * get errorCode
     * 
     * @return Returns the errorCode.<br>
     */
    public String getErrorCode() {
        return errorCode;
    }

    /**
     * set errorCode
     * 
     * @param errorCode The errorCode to set. <br>
     */
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    /**
     * get errorMsg
     * 
     * @return Returns the errorMsg.<br>
     */
    public String getErrorMsg() {
        return errorMsg;
    }

    /**
     * set errorMsg
     * 
     * @param errorMsg The errorMsg to set. <br>
     */
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

}
